package com.haiheng.library_base.db

import androidx.room.*

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2022/5/25 0025
 * @Version: 1.0
 */
@Dao
interface RecordDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(recordTable: RecordTable): Long

    @Delete
    suspend fun delete(recordTable: RecordTable): Int

    @Update
    suspend fun update(recordTable: RecordTable): Int

    @Query("SELECT * FROM record_table WHERE `status` = :status ORDER BY id DESC LIMIT 1")
    suspend fun findByKey(status: Int): RecordTable?

    @Query("SELECT COUNT(id) FROM record_table WHERE  `status` = :status AND  `recordType` = :recordType AND createDate BETWEEN :start AND :end")
    fun queryTodayCount(recordType : String,status: Int,start:Long,end:Long):Int

    @Query("SELECT COUNT(id) FROM record_table WHERE `recordType` = :recordType AND createDate BETWEEN :start AND :end")
    fun queryTodayTotalCount(recordType : String,start:Long,end:Long):Int
}